
/**
 * 通过查找表的对象的方式来编写 reducer\
 * 对象的每一个 key 都是 action type 值是 reducer 函数
 */
function createReducer(initState, reducers) {
  return function(state = initState, action) {
    const reducer = reducers[action.type]
    if(reducer) return reducer(state, action)
    return state
  }
}

export default createReducer;
